<!DOCTYPE html>
<html>
<head>
    <title>登录页面</title>
    <meta charset="UTF-8">
    <script src="/js/jquery.min.js"></script>
</head>
<body>

<h2>登录</h2>
<form>
    用户名：<input type="text" id="username">
    密 码：<input type="password" id="password">
    <input type="button" value="登录" onclick="login()">
</form>

    <script>
        function login() {
            var ajaxRequestParamObject = {
                type : 'GET',
                dataType : 'JSON',
                url : '/user/login.do',
                data : {
                    username : $('#username').val(),
                    password : $('#password').val()
                },
                success : function (result) {
                    if (result.code != 1000){
                        alert(result.message);
                        return;
                    }
                    alert('登录成功');
                    window.location.href = '/page/toPage.do?pageName=usercenter';
                }
            }

            $.ajax(ajaxRequestParamObject);
        }
    </script>

</body>
</html>